package com.young.servicehosp.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.google.common.collect.Maps;
import com.young.model.model.hosp.HospitalSet;
import com.young.servicehosp.mapper.HospitalSetMapper;
import com.young.servicehosp.service.HospitalSetService;
import org.apache.commons.collections4.CollectionUtils;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

@Service
public class HospitalSetServiceImpl extends ServiceImpl<HospitalSetMapper, HospitalSet> implements HospitalSetService {

    public static Map<String, List<HospitalSet>> hospitalSetListMap = Maps.newHashMap();


    public static Map<String, Page<HospitalSet>> hospitalSetPageMap = Maps.newHashMap();


    @Override
    public List<HospitalSet> getHospitalSetList() {
        List<HospitalSet> hospitalSetList = hospitalSetListMap.get("HospitalSetList");
        if (CollectionUtils.isEmpty(hospitalSetList)) {
            //调用service的方法
            hospitalSetList = this.list();
            hospitalSetListMap.put("HospitalSetList",hospitalSetList);
        }
        return hospitalSetList;
    }

    @Override
    public Page<HospitalSet> pageHospSet(Page<HospitalSet> page, LambdaQueryWrapper<HospitalSet> wrapper) {
        Page<HospitalSet> hospitalSetPage = hospitalSetPageMap.get("HospitalSetPage");
        if (hospitalSetPage == null) {
            hospitalSetPage = this.page(page, wrapper);
            hospitalSetPageMap.put("HospitalSetPage",hospitalSetPage);
        }
        return hospitalSetPage;
    }
}
